package t10086.Controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import t10086.Model.Entity.Order;
import t10086.Model.Http.Response;
import t10086.Service.OrderService;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/order")
public class OrderController {
    private final OrderService orderService;
    @Autowired
    public OrderController(OrderService orderService) {
        this.orderService = orderService;
    }


    @GetMapping("/unprocessed")
    public Response getUnprocessedOrders() {
        Response response = new Response();
        response.setMessage("Unprocessed Orders");
        List<Order>orders = orderService.getOrderByStatus(0);
        response.addData("orderList",orders);
        return response;
    }

    @GetMapping("/processed")
    public Response getProcessedOrders() {
        Response response = new Response();
        response.setMessage("Processed Orders");
        List<Order>orders = orderService.getOrderByStatus(1);
        response.addData("completedOrders",orders);
        return response;
    }

    @PostMapping("/test")
    public Response test(@RequestBody Map<String,Object> map) {
        System.out.println(map.get("lyx"));
        return  new Response();
    }



}
